package com.rich.dmr.databases;

import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DataBaseConnection extends SQLiteOpenHelper {
	private static String TAG = "rich---MyDatabaseHelper";
	private static final String db_name="frequency.db";
	private static final int version=1;
	private static final String CREATE_FREQUENCY = "create table frequency (_id integer primary key autoincrement,"
			+ "channel integer,"
			+ "tx_frequency integer,"
			+ "rx_frequency integer);";

	public DataBaseConnection(Context context) {
		super(context, db_name, null, version);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		try {
			db.execSQL(CREATE_FREQUENCY);
			Log.d(TAG,"table create success");
		} catch (SQLException e) {
			e.printStackTrace();
			Log.d(TAG,"table create fail");
		}
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("drop table if exists frequency");
		onCreate(db);
		Log.d(TAG, "table upgrade fail");
	}
}
